<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        hgroup{
            display: flex;
            width: 300px;
            height: 50px;
            margin: 50px auto 0;
            border: 2px solid darkcyan;
        }
        hgroup h2{
            background: pink;
            border-radius: 10px;
            flex: 1;
            text-align: center;
            font-size: 40px;
        }
        ul{
            border: 2px solid darkcyan;
            width: 300px;
            margin: 0 auto;
            list-style: none;
            display: none;
        }
        ul:nth-of-type(1){
            display: block;
        }
    </style>
</head>
<body>
    
    <hgroup>
        <h2>yi</h2>
        <h2>er</h2>
        <h2>san</h2>
    </hgroup>
    <ul >
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
        <li>5</li>
        <li>6</li>
    </ul>
    <ul >
        <li>11</li>
        <li>22</li>
        <li>33</li>
        <li>44</li>
        <li>55</li>
        <li>66</li>
    </ul>
    <ul >
        <li>111</li>
        <li>222</li>
        <li>333</li>
        <li>444</li>
        <li>555</li>
        <li>666</li>
    </ul>
    <script>
        //2 选项卡 页面中有一个选项卡 选项卡由两部分组成 上面的标题(3个)与下面的内容（只有一块区域）
        //获取标题和ul
        var list = document.getElementsByTagName("ul")
        var btn1 = document.querySelectorAll("hgroup h2")[0]
        var btn2 = document.querySelectorAll("hgroup h2")[1]
        var btn3 = document.querySelectorAll("hgroup h2")[2]

        //点击传参
        btn1.onclick = function () {
                fn(0)
        }
        btn2.onclick = function () {
                fn(1)
        }
        btn3.onclick = function () {
                fn(2)
        }
        //排它模块
        function fn(a){
            for(var i = 0;i < list.length;i++){
                list[i].style.display = "none"
            }
            list[a].style.display = "block"
        }
    </script>
</body>
</html>